Skip to content

UID2-7641: Remove support for V2 refresh tokens - #2718

Merged
samin-ttd merged 6 commits into
mainfrom
sra-UID2-7641-fix-refresh-padding-oracle-vulnerability
Sep 3, 2026
Merged

UID2-7641: Remove support for V2 refresh tokens#2718
samin-ttd merged 6 commits into
mainfrom
sra-UID2-7641-fix-refresh-padding-oracle-vulnerability

Conversation

@samin-ttd

@samin-ttd samin-ttd commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

V2 refresh tokens are AES-CBC encrypted, which is what makes this class of padding oracle possible in the first place. All refresh tokens issued today are V3 (AES-GCM, an authenticated mode with no padding-oracle equivalent), so V2 refresh token decoding is dead weight kept only for backward compatibility. Removing it eliminates the vulnerable code path entirely rather than just papering over its error handling.

Change

  • Added a catch-all Exception handler around refresh token decoding.
  • Removed decodeRefreshTokenV2 and the V2 branch in decodeRefreshToken — any V2-formatted refresh token now fails the same generic version check as other malformed input.
  • Removed the now-unreachable encodeV2(RefreshToken, ...) and its case V2 in encode(RefreshToken, ...) (refresh tokens have only ever been issued as V3 since UIDOperatorService.refreshTokenVersion is hardcoded to TokenVersion.V3).

Testing

  • Send requests crafted to trigger padding against the endpoint both before and after the change: ensure the response is 500 before and 400 after.
  • Full test suite passes (mvn test): 761 tests, 0 failures, 0 errors.
  • Confirmed no remaining references to decodeRefreshTokenV2 / encodeV2(RefreshToken...) anywhere in the codebase.

@samin-ttd
samin-ttd force-pushed the sra-UID2-7641-fix-refresh-padding-oracle-vulnerability branch from 0690322 to b220bdf Compare September 2, 2026 05:50
@samin-ttd
samin-ttd force-pushed the sra-UID2-7641-fix-refresh-padding-oracle-vulnerability branch from c82fcee to 7cfb5b1 Compare September 2, 2026 23:01
@samin-ttd samin-ttd changed the title UID2-7641: Fix padding oracle vulnerability in token/refresh UID2-7641: Remove support for V2 refresh tokens Sep 3, 2026
Comment thread src/main/java/com/uid2/operator/vertx/UIDOperatorVerticle.java Outdated
mcollins-ttd
mcollins-ttd previously approved these changes Sep 3, 2026
@samin-ttd
samin-ttd merged commit 14ae5b5 into main Sep 3, 2026
10 checks passed
@samin-ttd
samin-ttd deleted the sra-UID2-7641-fix-refresh-padding-oracle-vulnerability branch September 3, 2026 23:45
@mcollins-ttd
mcollins-ttd requested a balanced review from Copilot September 3, 2026 23:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Malformed refresh tokens can still escape as exceptions and return HTTP 500 instead of the intended 400 response.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Removes legacy AES-CBC V2 refresh-token support, leaving authenticated V3 refresh tokens as the supported format.

Changes:

  • Rejects V2 refresh-token decoding.
  • Removes V2 refresh-token encoding.
File summaries
File Description
src/main/java/com/uid2/operator/service/EncryptedTokenEncoder.java Removes V2 refresh-token encode/decode paths.
Review details

Suppressed comments (1)

src/main/java/com/uid2/operator/service/EncryptedTokenEncoder.java:91

  • The newly unsupported V2 decode path has no automated regression coverage. TokenEncodingTest.testRefreshTokenEncoding only covers V3/V4, while the endpoint's invalid-token cases use generic strings that do not represent a V2 token. Add a fixed V2-formatted token (including the padding-oracle-style malformed variants from the manual test) and assert decoding throws ClientInputValidationException and the refresh endpoint returns 400.
            if (b.getByte(1) == TokenVersion.V3.rawVersion) {
                return decodeRefreshTokenV3(b, bytes);
            }
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/com/uid2/operator/service/EncryptedTokenEncoder.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants